import 'package:flutter/material.dart';
import 'package:flutterproject/util/extension/extension_util.dart';
import 'package:flutterproject/util/extension/widget_extension.dart';
import 'package:flutterproject/util/margin_padding_util.dart';
import 'package:flutterproject/widget/text/text_common.dart';
import 'package:get/get.dart';

class AppBarCommon extends StatelessWidget implements PreferredSizeWidget {
  final String title;
  final Widget? rightWidget;
  final VoidCallback? leftClick;
  final Color? bgColor;
  final Color? titleColor;
  final Color? leftColor;

  const AppBarCommon({
    Key? key,
    required this.title,
    this.rightWidget,
    this.leftClick,
    this.bgColor,
    this.titleColor,
    this.leftColor,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
      width: Get.width,
      color: bgColor ?? Colors.white,
      padding: MarginPaddingUtil.symmetric(vertical: 40, horizontal: 43),
      child: Column(
        children: [
          SizedBox(height: MediaQuery.of(context).padding.top),
          Row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: [
              Icon(
                Icons.keyboard_arrow_left,
                size: 50.sp,
                color: leftColor ?? Color(0xFFFF414141),
              ).addClickEvent(() {
                if (leftClick == null) {
                  Get.back();
                } else {
                  leftClick!.call();
                }
              }),
              TextCommon(
                title,
                color: titleColor ?? Color(0xFFFF414141),
                size: 36.sp,
              ),
              rightWidget ??
                  SizedBox(
                    width: 50.width,
                  )
            ],
          ),
        ],
      ),
    );
  }

  @override
  // TODO: implement preferredSize
  Size get preferredSize => Size(Get.width, 80.height);
}
